package priv.mill.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import priv.mill.mapper.DeptMapper;
import priv.mill.mapper.EmployeeMapper;
import priv.mill.model.Employee;
import priv.mill.service.EmployeeService;

@Controller
@RequestMapping("employee")
public class EmployeeController {
	
	@Resource
	private EmployeeService employeeService;
	
	@Resource
	private EmployeeMapper employeeMapper;
	
	@GetMapping("byId")
	@ResponseBody
	public Object findById(int id,String name) {
		return employeeMapper.findById(id,name);
	}
	@GetMapping("all")
	@ResponseBody
	public List<Employee> findAll(){
		try {
			return employeeService.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	@GetMapping("all_two")
	@ResponseBody
	public Object findAllTwo() {
		return employeeMapper.findAllTwo();
	}
	@Resource
	private DeptMapper deptMapper;
	@GetMapping("dept")
	@ResponseBody
	public Object findDept(Integer deptId) {
		return deptMapper.findById(deptId);
				
	}
}
